package com.neusoft.chess.view;


import com.neusoft.chess.BingChess;
import com.neusoft.chess.Chess;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.HashMap;
import java.util.Map;

public class GamePanel extends JPanel {
    private Chess selectedChess;//选中被保存的棋子
    private Map<Point,Chess> map;
    public GamePanel(){
        addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                int x=e.getX();
            }
        });
    }
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        drawQipan(g);
    }
    /**
     * 绘制棋盘背景
     * @param  g
     */
    private  void drawQipan(Graphics g){
        Image bg=Toolkit.getDefaultToolkit().getImage("pic/qipan.jpg");
        g.drawImage(bg,0,0,this);
    }

    /**
     * 创建所有棋子但是而不负责绘画
     */
    private  void createChess(){
        BingChess c=new BingChess(1,0);
        map=new HashMap<>();
        map.put(c.getP(),c);
    }
}
